package com.ljh.localmusic.ui.component

import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import com.ljh.localmusic.data.local.models.AudioItem

/**
 * author：LJH on 2025/9/15 17:10
 *
 */


@Composable
fun MusicListDialog(
    modifier: Modifier = Modifier,
    musicList: List<AudioItem>,
    onItemClicked:(AudioItem) -> Unit,
    onDismiss:() -> Unit
) {

    Dialog(
        onDismissRequest = onDismiss
    ) {
        Surface(
            modifier = Modifier
                .height(600.dp)
                .clip(RoundedCornerShape(12.dp))
        ) {
            LazyColumn(
                modifier = Modifier.padding(8.dp)
            ) {
                items(musicList){ musicItem ->
                    MusicItemCard(
                        modifier = modifier,
                        audioItem = musicItem
                    ){
                        onItemClicked(musicItem)
                    }
                }
            }
        }
    }

}